package com.lashou.chunshen.lashoutuangou.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.lashou.chunshen.lashoutuangou.MainActivity;
import com.lashou.chunshen.lashoutuangou.R;
import com.lashou.chunshen.lashoutuangou.core.BaseActivity;
import com.lashou.chunshen.lashoutuangou.core.BaseFragment;
import com.lashou.chunshen.lashoutuangou.tools.SPUtils;

/**
 * Created by momo on 2016/8/31.
 */
public class SplashActivity extends BaseActivity {
    boolean isfirststar = true;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        //是否第一次加载
        isfirststar = (boolean) SPUtils.get(this, "isfirststar", true);

        // 闪屏的核心代码
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {

                Intent intent;
                if (!isfirststar) {
                    intent = new Intent(SplashActivity.this,
                            MainActivity.class); // 从启动动画ui跳转到主ui
                } else {
                    //是第一次加载
                    SPUtils.put(SplashActivity.this, "isfirststar", false);
                    intent = new Intent(SplashActivity.this,
                            LoadingActivity.class); // 从启动动画ui跳转到主ui
                }
                startActivity(intent);
                finish();

            }
        }, 3000); // 启动动画持续3秒钟
    }

    @Override
    protected BaseFragment getFirstFragment() {
        return null;
    }

    @Override
    protected int getContentViewId() {
        return R.layout.activity_splash;
    }

    @Override
    protected int getFragmentContentId() {
        return 0;
    }

    @Override
    protected boolean isNeedTitleBar() {
        return false;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
